﻿using Resn.WhuPub.BLL;
using Resn.WhuPub.DAL;
using Resn.WhuPub.DML;
using System;

namespace Resn.WhuPub.BLL
{
        /// <summary>
        /// 实现学历的属性与方法
        /// </summary>
        public class Educational : Entity<EducationalModel>
        {
                /// <summary>
                /// 创建学历实例
                /// </summary>
                /// <param name="model">学历模型</param>
                public Educational(EducationalModel model)
                        : base(model)
                {
                }

                #region 属性

                #region 基本属性

                
                /// <summary>
                /// 获取联系人标识
                /// </summary>
                /// <value>
                /// 联系人标识
                /// </value>
                public string ContactId
                {
                        get
                        {
                                return Model.ContactId;
                        }
                }

                /// <summary>
                /// 获取或设置毕业学校
                /// </summary>
                /// <value>
                /// 毕业学校
                /// </value>
                public string GraduateSchool
                {
                        get
                        {
                                return Model.GraduateSchool;
                        }
                        set
                        {
                                Model.GraduateSchool = value;
                        }
                }

                /// <summary>
                /// 获取或设置学历层次
                /// </summary>
                /// <value>
                /// 学历层次
                /// </value>
                public EducationalLevel EducationalLevel
                {
                        get
                        {
                                return (EducationalLevel)Enum.Parse(typeof(EducationalLevel), Model.EducationalLevel);
                        }
                        set
                        {
                                Model.EducationalLevel = value.ToString();
                        }
                }

                /// <summary>
                /// 获取或设置专业标识
                /// </summary>
                /// <value>
                /// 专业标识
                /// </value>
                public string MajorId
                {
                        get
                        {
                                return Model.MajorId;
                        }
                        set
                        {
                                Model.MajorId = value;
                        }
                }

                /// <summary>
                /// 获取或设置起始时间
                /// </summary>
                /// <value>
                /// 起始时间
                /// </value>
                /// <remarks>
                /// 时间显示精度精确到月，存储时值为XXXX年-X月-1日 00：00：00
                /// </remarks>
                public DateTime StartTime
                {
                        get
                        {
                                return Model.StartTime;
                        }
                        set
                        {
                                Model.StartTime = value;
                        }
                }

                /// <summary>
                /// 获取或设置结束时间
                /// </summary>
                /// <value>
                /// 结束时间
                /// </value>
                /// <remarks>
                /// 时间显示精度精确到月，存储时值为XXXX年-X月-1日 00：00：00
                /// </remarks>
                public DateTime EndTime
                {
                        get
                        {
                                return Model.EndTime;
                        }
                        set
                        {
                                Model.EndTime = value;
                        }
                }

                #endregion 基本属性

                

                /// <summary>
                /// 获取专业
                /// </summary>
                /// <value>
                /// 专业
                /// </value>
                public Major Major
                {
                        get
                        {
                                var model = DBStorage.Instance.Select<MajorModel>(MajorId);
                                return new Major(model);
                        }
                }

                /// <summary>
                /// 获取专业名称
                /// </summary>
                /// <value>
                /// 专业名称
                /// </value>
                public string MajorName
                {
                        get { return Major.Name; }
                }

                #endregion 属性

                #region 方法

                /// <summary>
                /// 获取指定标识的对象
                /// </summary>
                /// <param name="id">标识</param>
                /// <returns></returns>
                public static Educational Select(string id)
                {
                        return Select<Educational>(id);
                }

                #endregion

        }
}